// 头部滚动条，过两秒隐藏
var myfirst = document.querySelector('.w-loading');
setTimeout(function () {
	myfirst.style.opacity = '0';
}, 1000);

//
// var sousuo=document.querySelector('.btn-search')
var yinc=document.querySelector('.header-search')
var ss=document.querySelector('.ss')
var ch=document.querySelector('.ch')
ss.onclick=function(){
    yinc.style.display = 'block';
    ch.style.display = 'block';
    this.style.display = 'none'
  }
ch.onclick=function(){
    yinc.style.display = 'none';
    ss.style.display = 'block'
    this.style.display = 'none';
}
//

//轮播图开始
var ul = document.querySelector('#ul-lb');
var li=document.querySelectorAll('#ul-lb>li');
var jt=document.querySelectorAll('.jt');
var index=0;
var xd=null;
function run(num){
    clearInterval(xd);
       xd=setInterval(function(){
           var width=(num-ul.offsetLeft)/10;
           width=width>0?Math.ceil(width):Math.floor(width);
           ul.style.left=ul.offsetLeft+width+'px';
       },1000/50);
    }
jt[0].onclick=function(){
    index--;
    if(index==-2){
        ul.style.left='-400px';
        index=0;
    }
    run(index*li[0].offsetWidth);
}
jt[1].onclick=function(){
        index--;
        if(index==-2){
            index=0;
        }
    run(index*li[0].offsetWidth);
}
//轮播图结束

//选项卡开始
var tabli = document.querySelectorAll('.tab>li');
var div = document.querySelectorAll('.bd>div');

for (var w = 0; w < tabli.length; w++) {
	tabli[w].abc = w;
	tabli[w].onmouseover = function() {
		for (var t = 0; t < tabli.length; t++) {
			tabli[t].className=''
			div[t].className = 'none';
		}
		this.className='on'
		div[this.abc].className = '';
	}
}
//选项卡结束
//底部开始
var coping = document.getElementsByClassName('w-loading');
var icon = document.getElementsByClassName('logo-uicon');
// var height=document.body.scrolltop;
// var height=document.documentElement.scrollTop;
// var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var res;
//遍历
    //给每个li绑定一个属性  属性值是i
    icon[0].a=0;
    //给每一个li绑定一个点击事件
    icon[0].onclick=function(){
        //调用运动函数
        res = running(coping[this.a].offsetTop);
    }
var xh=null;
function running(num){ //目标值   500    0
    clearInterval(xh);
    xh=setInterval(function(){
        var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
        //目标值与当前值之间的距离    
        var jl=(num-scrollTop)/10;
        jl=jl>0?Math.ceil(jl):Math.floor(jl);//本次执行需要移动的距离
        document.body.scrollTop=scrollTop+jl;
        if(document.body.scrollTop) {
                document.body.scrollTop=scrollTop+jl;
            } else {
                document.documentElement.scrollTop=scrollTop+jl;
        }
        //判断当前文档滚动高度是否与目标一致
        if(num==scrollTop){
            //停止循环
            clearInterval(xh);
        }
    },1000/100);
    return num;
}
//底部结束